<?php


namespace app\admin\controller\general;


use app\admin\controller\Controller;
use app\admin\model\BaseSetting;

class Agent extends Controller
{
    /**
     * 站点设置
     * @return mixed
     * @throws \think\exception\DbException
     */
    public function index()
    {

        $model = BaseSetting::detail('agent');

        if (!$this->request->isAjax()) {
            return $this->fetch('index', compact('model'));
        }

        if ($model->edit('agent',$this->postData('agent'))) {
            return $this->renderSuccess('更新成功');
        }
        return $this->renderError($model->getError() ?: '更新失败');
    }


    /**
     * 发票设置
     * @return array|mixed
     * @throws \think\exception\DbException
     */
    public function invoice(){
        $model = BaseSetting::detail('invoice');
        if (!$this->request->isAjax()) {
            return $this->fetch('invoice', compact('model'));
        }

       if ($model->edit('invoice',$this->postData('invoice'))) {
            return $this->renderSuccess('更新成功');
        }
        return $this->renderError($model->getError() ?: '更新失败');
    }


}